package com.tenebrous.jestic.mapper.idao.framwork.meber.organ;

import com.tenebrous.jestic.entity.framwork.meber.organ.OrgUser;
import com.tenebrous.jestic.entity.framwork.meber.organ.OrgUserAccount;
import com.tenebrous.jestic.mapper.ISuperMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

//@Mapper
public interface OrgUserMapper extends ISuperMapper<OrgUser> {

    OrgUser selectById(@Param("id") String id);

    OrgUser selectByUsername(@Param("username") String username);

    List<OrgUser> selectByRoleid(@Param("roleid") String roleid);

    List<OrgUser> selectByCondition(@Param("companyid") String companyid, @Param("departmentid") String departmentid, @Param("etype") String etype, @Param("estate") String estate, @Param("dstate") Integer dstate,
                                    @Param("politicalCode") String politicalCode, @Param("edutionCode") String edutionCode, @Param("degreeCode") String degreeCode,
                                    @Param("sexCode") String sexCode, @Param("marryCode") String marryCode,
                                    @Param("realname") String realname);

    OrgUserAccount selectAccountByUsername(@Param("username") String username);

    List<Map<String, Object>> selectStateCount(@Param("companyid") String companyid, @Param("departmentid") String departmentid);

    List<Map<String, Object>> selectEstateCount(@Param("companyid") String companyid, @Param("departmentid") String departmentid);

    List<Map<String, Object>> selectEtypeCount(@Param("companyid") String companyid, @Param("departmentid") String departmentid);

    Integer selectRegularEmployCount(@Param("companyid") String companyid, @Param("departmentid") String departmentid);

    List<OrgUser> selectUserByDepartmentids(@Param("departmentids") String[] departmentids, @Param("etype") String etype);

    List<Map<String, Object>> selectAnalysEdution(@Param("companyid") String companyid);

    List<Map<String, Object>> selectAnalysEdutionCompany(@Param("edution") String edution);

    List<Map<String, Object>> selectAnalysEdutionDepartment(@Param("companyid") String companyid, @Param("edution") String edution);

    List<Map<String, Object>> selectAnalysAge(@Param("companyid") String companyid);

    List<Map<String, Object>> selectAnalysAgeCompany(@Param("agerange") String agerange);

    List<Map<String, Object>> selectAnalysAgeDepartment(@Param("companyid") String companyid, @Param("agerange") String agerange);

    List<OrgUser> selectAnalysAgeDepartmentUsers(@Param("departmentid") String departmentid, @Param("agerange") String agerange);

    List<Map<String, Object>> selectAnalysSex(@Param("companyid") String companyid);

    List<Map<String, Object>> selectAnalysSexCompany(@Param("sex") String sex);

    List<Map<String, Object>> selectAnalysSexDepartment(@Param("companyid") String companyid, @Param("sex") String sex);

    List<OrgUser> selectAnalysSexDepartmentUsers(@Param("departmentid") String departmentid, @Param("sex") String sex);

    List<Map<String, Object>> selectAnalysCompany();

    List<Map<String, Object>> selectAnalysCompanyDepartment(@Param("companyid") String companyid);

    List<OrgUser> selectAnalysCompanyDepartmentUsers(@Param("departmentid") String departmentid);

    List<OrgUser> selectMailByCondition(@Param("realname") String realname, @Param("mobile") String mobile, @Param("companyid") String companyid, @Param("departmentid") String departmentid);

    @Delete("DELETE FROM ORG_USER WHERE DEPARTMENTID=#{companyid}")
    void deleteByDepartid(@Param("companyid") String companyid);

    @Select("SELECT * FROM ORG_USER WHERE DEPARTMENTID=#{did}")
    List<OrgUser> queryListByDepartmentid(@Param("did") String did);

    @Select("SELECT * FROM ORG_USER WHERE IDCARD=#{idcard}")
    OrgUser selectByIdcard(@Param("idcard") String idcard);

    List<OrgUser> selectByUserids(@Param("userids") String[] userids);

    @Select("SELECT U.* FROM ORG_USER U WHERE U.MOBILE=#{mobile}")
    OrgUser selectByMobile(@Param("mobile") String mobile);

//    @Select("SELECT ou.ID as id,ou.REALNAME as realname,ou.ESTATE as estate,ou.MOBILE as mobile,ou.CREATE_DATE as createDate from org_user ou ")
//    List<OrgUserVo> selectByUserList(@Param("noticeId") String noticeId);
}